package com.yunlc.kubernetes.traefik.models;

import com.google.gson.annotations.SerializedName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@ApiModel(description = "IngressRouteSpec describes the IngressRoute the user wishes to exist.")
public class TraefikV1alpha1IngressSpec {

    @SerializedName("entryPoints")
    private List<String> entryPoints = null;

    @SerializedName("routes")
    private List<TraefikV1alpha1IngressRoute> routes = null;

    @SerializedName("tls")
    private TraefikV1alpha1IngressTLS tls = null;

    public TraefikV1alpha1IngressSpec entryPoints(List<String> entrypoints) {
        this.entryPoints = entrypoints;
        return this;
    }

    public TraefikV1alpha1IngressSpec addEntryPointItem(String entrypoint) {
        if (this.entryPoints == null) {
            this.entryPoints = new ArrayList<String>();
        }
        this.entryPoints.add(entrypoint);
        return this;
    }

    @ApiModelProperty(value = "entrypoints")
    public List<String> getEntryPoints() {
        return entryPoints;
    }

    public void setEntryPoints(List<String> entrypoints) {
        this.entryPoints = entrypoints;
    }

    public TraefikV1alpha1IngressSpec routes(List<TraefikV1alpha1IngressRoute> routes) {
        this.routes = routes;
        return this;
    }

    public TraefikV1alpha1IngressSpec addRouteItem(TraefikV1alpha1IngressRoute routeItem) {
        if (this.routes == null) {
            this.routes = new ArrayList<TraefikV1alpha1IngressRoute>();
        }
        this.routes.add(routeItem);
        return this;
    }

    @ApiModelProperty(value = "A list of host rules used to configure the Ingress. If unspecified, or no rule matches, all traffic is sent to the default backend.")
    public List<TraefikV1alpha1IngressRoute> getRoutes() {
        return routes;
    }

    public void setRoutes(List<TraefikV1alpha1IngressRoute> routes) {
        this.routes = routes;
    }

    public TraefikV1alpha1IngressSpec tls(TraefikV1alpha1IngressTLS tls) {
        this.tls = tls;
        return this;
    }

    @ApiModelProperty(value = "TLS configuration. Currently the Ingress only supports a single TLS port, 443. If multiple members of this list specify different hosts, they will be multiplexed on the same port according to the hostname specified through the SNI TLS extension, if the ingress controller fulfilling the ingress supports SNI.")
    public TraefikV1alpha1IngressTLS getTls() {
        return tls;
    }

    public void setTls(TraefikV1alpha1IngressTLS tls) {
        this.tls = tls;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        TraefikV1alpha1IngressSpec extensionsV1beta1IngressSpec = (TraefikV1alpha1IngressSpec) o;
        return Objects.equals(this.entryPoints, extensionsV1beta1IngressSpec.entryPoints) &&
                Objects.equals(this.routes, extensionsV1beta1IngressSpec.routes) &&
                Objects.equals(this.tls, extensionsV1beta1IngressSpec.tls);
    }

    @Override
    public int hashCode() {
        return Objects.hash(entryPoints, routes, tls);
    }


    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class TraefikV1alpha1IngressSpec {\n");

        sb.append("    entryPoints: ").append(toIndentedString(entryPoints)).append("\n");
        sb.append("    routes: ").append(toIndentedString(routes)).append("\n");
        sb.append("    tls: ").append(toIndentedString(tls)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces
     * (except the first line).
     */
    private String toIndentedString(Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }

}
